<template>
	<view class="jbxx">
		<view class="mould1">
			<view class="centerline">
				<view class="lable">
					<span style="color: #F53F3F;">*</span>
					<span>与自己的关系：</span>
				</view>
				<view class="righthd">
					{{numtext('relationship', userobj['relationship'])}}
				</view>
			</view>
			<view class="centerline">
				<view class="lable">
					<span style="color: #F53F3F;">*</span>
					<span>姓名：</span>
				</view>
				<view class="righthd">
					{{ userobj.user_name||'--'}}
				</view>
			</view>
			<view class="centerline">
				<view class="lable">
					<span style="color: #F53F3F;">*</span>
					<span>性别：</span>
				</view>
				<view class="righthd">
					{{numtext('gender',userobj.gender)||'--'}}
				</view>
			</view>
			<view class="centerline">
				<view class="lable">
					<span style="color: #F53F3F;">*</span>
					<span>出生日期：</span>
				</view>
				<view class="righthd">
					{{userobj.birthday||'--'}}
				</view>
			</view>
			<view class="centerline">
				<view class="lable">
					<span style="color: #F53F3F;">*</span>
					<span>身高：</span>
				</view>
				<view class="righthd">
					{{userobj.height||'--'}}cm
				</view>
			</view>
			<view class="centerline">
				<view class="lable">
					<span style="color: #F53F3F;">*</span>
					<span>体重：</span>
				</view>
				<view class="righthd">
					{{userobj.weight||'--'}}kg
				</view>
			</view>
			<view class="centerline">
				<view class="lable">
					<span style="color: #F53F3F;">*</span>
					<span>BMI：</span>
				</view>
				<view class="righthd">
					{{userobj.bmi||'--'}}
				</view>
			</view>
			<view class="centerline">
				<view class="lable">
					<span style="color: #F53F3F;">*</span>
					<span>症状：</span>
				</view>
				<view class="righthd">
					{{userobj.symptom||'--'}}
				</view>
			</view>
			<view class="centerline">
				<view class="lable">
					<span style="color: #F53F3F;">*</span>
					<span>初次就诊时间：</span>
				</view>
				<view class="righthd">
					{{userobj.first_illness_date||'--'}}
				</view>
			</view>
		</view>
		<view class="mould1" style="margin-top: 32rpx;">
			<view class="centerline">
				<view class="lable">
					<span>手机号：</span>
				</view>
				<view class="righthd">
					{{userobj.mobile||'--'}}
				</view>
			</view>

		</view>
		<view class="mould1" style="margin-top: 32rpx;">
			<view class="centerline">
				<view class="lable">
					<span>是否吸烟：</span>
				</view>
				<view class="righthd">
					{{numtext('is_smoke', userobj.is_smoke) ||'--'}}
				</view>
			</view>
			<view class="centerline">
				<view class="lable">
					<span>是否酗酒：</span>
				</view>
				<view class="righthd">
					{{numtext('is_drinking', userobj.is_drinking) ||'--'}}
				</view>
			</view>
		</view>
		<view class="mould1" style="margin-top: 32rpx;">
			<view class="centerline">
				<view class="lable">
					<span>肝功能：</span>
				</view>
				<view class="righthd">
					{{numtext('liver', userobj.liver) ||'--'}}
				</view>
			</view>
			<view class="centerline">
				<view class="lable">
					<span>生育状况：</span>
				</view>
				<view class="righthd">
					{{numtext('fertility_status', userobj.fertility_status) ||'--'}}
				</view>
			</view>
		</view>
		<view class="mould1" style="margin-top: 32rpx;">
			<view class="centerline">
				<view class="lable">
					<span>既往史：</span>
				</view>
				<view class="righthd">
					{{ userobj.past_history||'--'}}
				</view>
			</view>
			<view class="centerline">
				<view class="lable">
					<span>家族病史：</span>
				</view>
				<view class="righthd">
					{{ userobj.family_history||'--'}}
				</view>
			</view>
			<view class="centerline">
				<view class="lable">
					<span>药物过敏：</span>
				</view>
				<view class="righthd">
					{{ userobj.drug_allergy||'--'}}
				</view>
			</view>
			<view class="centerline">
				<view class="lable">
					<span>食物过敏：</span>
				</view>
				<view class="righthd">
					{{ userobj.food_allergy||'--'}}
				</view>
			</view>
		</view>
	</view>
	<view class="" style="height: 200rpx;">

	</view>
	<view class="fixed">
		<view class="btn" @click="gopage()">
			编辑资料
		</view>
	</view>
</template>

<script setup>
	const arr = reactive([{
		'name': '本人',
		id: 1
	}, {
		'name': '父母',
		id: 2
	}, {
		'name': '子女',
		id: 3
	}, {
		'name': '爱人',
		id: 4
	}, {
		'name': '其他',
		id: 5
	}])
	const arr1 = reactive([{
		'name': '身份证',
		id: 1
	}, {
		'name': '港澳通行证',
		id: 2
	}, {
		'name': '签证',
		id: 3
	}])

	const arr2 = reactive([{
		'name': '否',
		id: 0
	}, {
		'name': '是',
		id: 1
	}])

	const arr3 = reactive([{
		'name': '正常',
		id: 1
	}, {
		'name': '异常',
		id: 2
	}])
	const arr4 = reactive([{
		'name': '未生育',
		id: 0
	}, {
		'name': '已生育',
		id: 1
	}])
	const xingbie = reactive([{
		'name': '男',
		id: '1'
	}, {
		'name': '女',
		id: '0'
	}])

	import {
		$api
	} from '@/ulm';
	import {
		onMounted,
		ref,
		reactive,
		defineProps
	} from 'vue'

	const props = defineProps({
		userobj: {
			type: Object,
			required: true
		},
	})

	function numtext(typestr, id) {
		if (typestr == 'relationship') {
			var ind = arr.findIndex(item => item.id == id)
			if (ind == -1) {
				return ''
			} else {
				return arr[ind]['name']
			}
		} else if (typestr == 'card_type') {
			var ind = arr1.findIndex(item => item.id == id)
			if (ind == -1) {
				return ''
			} else {
				return arr1[ind]['name']
			}
		} else if (typestr == 'card_type') {
			var ind = arr1.findIndex(item => item.id == id)
			if (ind == -1) {
				return ''
			} else {
				return arr1[ind]['name']
			}
		} else if (typestr == 'is_smoke') {
			var ind = arr2.findIndex(item => item.id == id)
			if (ind == -1 && id != 0) {
				return ''
			} else {
				return arr2[ind]['name']
			}
		} else if (typestr == 'is_drinking') {
			var ind = arr2.findIndex(item => item.id == id)
			if (ind == -1 && id != 0) {
				return ''
			} else {
				return arr2[ind]['name']
			}
		} else if (typestr == 'liver') {
			var ind = arr3.findIndex(item => item.id == id)
			if (ind == -1) {
				return ''
			} else {
				return arr3[ind]['name']
			}
		} else if (typestr == 'fertility_status') {
			var ind = arr4.findIndex(item => item.id == id)

			console.log(ind, 'id--------------');
			if (ind == -1 && id != 0) {
				return ''
			} else {
				return arr4[ind]['name']
			}
		} else if (typestr == 'gender') {
			var ind = xingbie.findIndex(item => item.id == id)
			console.log(ind, id, 'id-------------699-');
			if (ind == -1) {
				return ''
			} else {
				return xingbie[ind]['name']
			}
		}

	}


	function gopage() {
		uni.navigateTo({
			url: '/sub_index/index/bianjigerenziliao'
		})
	}
</script>

<style lang="scss">
	.fixed {
		width: 100%;
		height: 194rpx;
		background: #FFFFFF;
		box-shadow: 0rpx -6rpx 14rpx 0rpx rgba(0, 0, 0, 0.03);
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		position: fixed;
		bottom: 0%;

		.btn {
			width: 686rpx;
			height: 82rpx;
			background: #2AB4F5;
			border-radius: 12rpx 12rpx 12rpx 12rpx;
			text-align: center;
			line-height: 82rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			font-size: 32rpx;
			color: #FFFFFF;
			margin: auto;
			margin-top: 32rpx;
		}
	}

	.jbxx {
		width: 686rpx;
		margin: auto;
		overflow: hidden;

		.mould1 .centerline:last-child {
			border: none !important;
		}

		.mould1 {
			width: 100%;
			box-shadow: 0rpx 4rpx 10rpx 0rpx rgba(0, 0, 0, 0.03);
			border-radius: 24rpx 24rpx 24rpx 24rpx;
			overflow: hidden;
			padding: 8rpx 0;
			background: #FFFFFF;

			.centerline {
				width: 630rpx;
				min-height: 88rpx;
				margin: auto;
				display: flex;
				align-items: center;
				justify-content: space-between;
				border-bottom: 2rpx solid #F2F3F5;

				.lable {
					font-size: 32rpx;
					color: #1D2129;
				}

				.righthd {
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 32rpx;
					color: #1D2129;
					text-align: right;
					max-width: 400rpx;
				}
			}
		}
	}
</style>